package com.upc.cisco.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.upc.cisco.dominio.PagoProfesor;
import com.upc.cisco.excepcion.DAOExcepcion;
import com.upc.cisco.negocio.GestionPagoProfesor;

@WebServlet("/ReportePagoProfesorServlet")
public class ReportePagoProfesorServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public ReportePagoProfesorServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doRequest(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doRequest(request, response);
	}

	protected void doRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		int codigo = 0;
		try {
			List<Integer> lstCodigos = new GestionPagoProfesor()
					.listarCodigosProfesoresPagos();
			for(int i=0 ; i < lstCodigos.size() ; i++){
				 codigo = lstCodigos.get(i);
			}
			List<PagoProfesor> lst = new GestionPagoProfesor().listar(codigo);
			request.setAttribute("PAGOSPROFESORES", lst);
			RequestDispatcher rd = request
					.getRequestDispatcher("reportePagoProfesor.jsp");
			rd.forward(request, response);
		} catch (DAOExcepcion e) {
			e.printStackTrace();
		}
	}

}
